home *** CD-ROM | disk | FTP | other *** search
Text File | 1994-10-17 | 2.5 KB | 109 lines | [TEXT/KAHL] |
- Graham.
- Here is sample code on how to use the TIFF code. It's fairly straight forward. You
- may need to change some things to suit your own application frame work. This code opens NeXT TIFF files
- as well as TIFF 5.0 (but not TIFF 6.0).
-
-
- First to open the file:
- display_image_GW = ReadTIFF( &fsp, ( **recHdl ).volName, TRUE, &imageInfo, &err, &r );
-
- if ( display_image_GW == NIL )
- {
- rBounds = r;
- }
- else
- {
- rBounds = display_image_GW->portRect;
- }
-
- display_window = MakeDisplayWindow( &rBounds, fsp.name ); // or what ever you do for your display windows
-
- w_palette = GetPalette( display_window ); // save the old palette and restore it when you dispose of the window
-
- InitPalette( );
-
- Now for updating:
-
- /************************************************************************
- ************************************************************************/
-
- void UpdateDisplayWindow( WindowPtr w, Rect *r )
- {
- Point origin;
- MyData **dataH;
- Rect copyRect;
- GrafPtr oldPort;
- RGBColor oldFore, oldBack;
- OSType type;
-
-
- if ( w == NIL )
- {
- return;
- }
-
- dataH = ( MyData ** ) GetWRefCon( w );
- type = ( **dataH ).fileType;
-
- origin.h = GetCtlValue( of your horizontal scrollbar );
- origin.v = GetCtlValue( of your vertical scrollbar );
-
- copyRect = *r;
- OffsetRect( ©Rect, origin.h, origin.v );
-
- GetForeColor( &oldFore );
- GetBackColor( &oldBack );
-
- GetPort( &oldPort );
- SetPort( w );
-
- ForeColor( blackColor );
- BackColor( whiteColor );
-
- LockPixels( display_image_GW->portPixMap );
-
- if ( type == 'TIFF' )
- {
- if ( display_image_GW )
- {
- CopyBits( ( BitMap * ) &display_image_GW->portPixMap, ( BitMap * ) &w->portBits,
- ©Rect, r, ( *TIFF_Rec_Hdl)->dither ? 64 : srcCopy, NIL );
- }
- else
- if ( ( *TIFF_Rec_Hdl )->ref != -1 )
- {
- DrawTIFF( ( *TIFF_Rec_Hdl )->ref, ( *TIFF_Rec_Hdl )->ti, copyRect, *r, ( *TIFF_Rec_Hdl )->dither );
- }
- }
-
- UnlockPixels( display_image_GW->portPixMap );
-
- SetPort( oldPort );
-
- RGBForeColor( &oldFore );
- RGBBackColor( &oldBack );
- }
-
-
- For scrolling:
-
- CalcDrawingRect( theWindow, &userContent ); // this is the area of the window less the scrollbars
-
- update = NewRgn( );
-
- ScrollRect( &userContent, hAmt, vAmt, update ); // hAmt/vAmt is the scroll value
-
- if ( update != NIL )
- {
- userContent = ( *update )->rgnBBox;
- DisposeRgn( update );
- }
-
- UpdateDisplayWindow( theWindow, &userContent );
-
-
- Good luck!!!! Any problems just send a message (I answer slowly or ( 204 ) 885 • 4519, I answer quickly
-
- Regards,
-
- James